package com.sakura.eduservice.controller;


import com.sakura.commonutils.R;
import com.sakura.eduservice.service.EduSubjectService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author sakura
 * @since 2020-10-19
 */
@RestController
@RequestMapping("/eduservice/subject")
public class EduSubjectController {
    @Autowired
    private EduSubjectService subjectService;

    @PostMapping("addSubject")
    @ApiOperation("获取上传过来文件，把文件内容读取出来")
    public R addSubject(MultipartFile file){
        //上传过来的excel文件
        subjectService.saveSubject(file,subjectService);
        return R.ok();
    }

    @ApiOperation("课程分类列表(树形)")
    @GetMapping("getAllSubject")
    public R getAllSubject(){
        return R.ok().data("list",subjectService.getAllOneTwoSubject());
    }



}

